package com.nio.page;

import android.content.Context;
import android.util.AttributeSet;
import android.widget.LinearLayout;

/**
 * Created by houlian.wang on 2016/11/28.
 */

public abstract class BaseLayout extends LinearLayout {
    private static final String TAG = "BaseLayout";
    private float downRawX, downRawY;
    private float deltaRawX, deltaRawY;
    private ControlLayout controlLayout;
    public BaseLayout(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    /*@Override
    public boolean onTouchEvent(MotionEvent event) {
        Log.d(TAG, "onTouchEvent");
        switch (event.getAction()) {
            case MotionEvent.ACTION_DOWN:
                Log.d(TAG, "ACTION_DOWN");
                downRawX = event.getRawX();
                downRawY = event.getRawY();
                break;
            case MotionEvent.ACTION_MOVE:
                Log.d(TAG, "ACTION_MOVE");

                break;
            case MotionEvent.ACTION_UP:
                Log.d(TAG, "ACTION_UP");
                deltaRawX = event.getRawX() - downRawX;
                deltaRawY = event.getRawY() - downRawY;
                double angle = Math.atan(Math.abs(deltaRawY)/Math.abs(deltaRawX));
                double compare = Math.PI*15/180;
                Log.d(TAG, "angle:" + angle + ",compare:" + compare);
                if (controlLayout != null) {
                    //controlLayout.changePage(deltaRawX);
                }
                break;
            case MotionEvent.ACTION_CANCEL:
                Log.d(TAG, "ACTION_CANCEL");
                break;
        }
        return super.onTouchEvent(event);
    }*/

    public void setControlLayout(ControlLayout controlLayout) {
        this.controlLayout = controlLayout;
    }
}
